home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple II Magazines (PO)
/
Nibble Volume 10, No. 12 (1989-12)(MindCraft Publishing)(Side A).zip
/
Nibble Volume 10, No. 12 (1989-12)(MindCraft Publishing)(Side A).po
/
FREESPACE.ASM.txt
< prev
next >
Wrap
Text File
|
1996-12-24
|
12KB
|
398 lines
*****************************
* FREESPACE.ASM Source Code *
* by Alan H. Stein *
* Copyright (c) 1989 *
* MindCraft Publ. Corp. *
* Concord, MA 01742 *
* Orca/M Assembler *
*****************************
KEEP FreeSpace
MCOPY FreeSpace.MAC
Period gequ $FFFF ;don't pass "run" code
EventMask gequ $FFFF ;handle all events
NDA START
dc i4'NDA_Open' ;open the NDA
dc i4'NDA_Close' ;close the NDA
dc i4'NDA_Action' ;perform NDA actions
dc i4'NDA_Init' ;startup/shutdown
dc i2'Period' ;Periodicity of "run" action
dc i2'EventMask' ;permitted events
dc C'##' ;Name in menu item form
dc C'Free Space' ;Text for NDA name
dc C'\H**',i1'0' ;id field + terminator
* Open NDA if not previously open. Returns ptr to NDA window on the stack,
* just above 3 byte return address. DM reserves this result space before
* calling NDA_Open w/JSL instruction.
NDA_Open ANOP
Result equ $05 ;result stack offset after jsl, phb
phb
phk
plb ;data bank = code bank
lda NDAActive ;FreeSpace window already open?
beq R1 ; no, so check drives & open window
jmp Ignore ; yes, so ignore
****************************************************************
* Get information from disks and save it in memory for use
* with Quickdraw
****************************************************************
R1 ANOP
lda #49
sta WindBot ;depth of window
stz DiskDataOffset ;initialize offset to data
add4 #DiskData,#19,DiskDataAddr ;store location of disk data
* Get information for first device
lda #dev_name_str
sta dev_name
lda #dev_name_str|-16
sta dev_name+2
bra get_vol_info
* Get information for next device
NextDev add4 dev_name,#4
cmp4 #dev_name_end,dev_name ;down with list of devices?
bcc N1 ;yes
get_vol_info volume vol_list
bcc SaveIt ;volume present -- store info
cmp #$11 ;device present?
bne NextDev ; yes, so check for next one
N1 jmp DoneWDevices
SaveIt ANOP
add2 WindBot,#12,WindBot ;add room for another line
lda #1
ldx DiskDataOffset
sta DiskData,x ;flag data good
ldx #VolumeName
clc
lda #DiskData
adc DiskDataOffset
adc #2 ;past flag
tay
lda #16 ;# bytes to transfer (less 1)
mvn VolumeName,DiskData ;transfer data
add2 DiskDataOffset,#41 ;prepare for next data
div4 total_blocks,#2,capacity ;divide by 2 to get K
PH4 capacity
PH4 DiskDataAddr
PH2 #11
PH2 #0
_long2Dec ;store as ASCII string
add2 DiskDataAddr,#11
div4 free_blocks,#2,free_blocks ;divide by 2 to get K
PH4 freeK
PH4 DiskDataAddr
PH2 #11
PH2 #0
_long2Dec ;store as ASCII string
add2 DiskDataAddr,#30 ;update
jmp NextDev
DoneWDevices ANOP
ldx DiskDataOffset
stz DiskData,X ;flag end of data
* Open window
pha ;space for result
pha
pushptr WindowDef
_NewWindow ;create and open NDA window
plx ;pop ptr (low)
pla ;pop ptr (high)
stx WindowPtr ;save ptr to window
sta WindowPtr+2
sta Result+2,s ;save Result on stack (high)
txa
sta Result,s ; (low)
PH4 WindowPtr
_SetSysWindow ;mark this as a DA window
lda #$FFFF
sta NDAActive ;set "open" flag
plb
RTL
****************************************************************
* Close the NDA if not already closed
****************************************************************
NDA_Close ANOP
phb
phk
plb ;data bank = code bank
lda NDAActive ;FreeSpace window open?
beq Ignore ; no, so branch
PH4 WindowPtr
_CloseWindow
stz NDAActive ;mark FreeSpace as closed
Ignore plb
RTL
****************************************************************
* Perform the NDA action
****************************************************************
NDA_Action ANOP
phb ;save data bank
phk
plb ;make data bank = program bank
phy ;save incoming data
phx
cmp #1 ;take action?
bne NoAction ; no, don't
jsr NDA_Event ; yes, check event
NoAction ANOP
lda #$FFFF ;say we took action
plx
ply ;fix stack
plb
RTL
* X, Y (pushed on stack) contain ptr to event record
NDA_Event ANOP
TheEvent equ $05 ;1 (base) + 2 (jsr) + 2 (phd)
phd
tsc
tcd ;align DP w/stack
lda [TheEvent] ;get "what" code
cmp #6 ;update event?
bne te1 ;not supported
jsr DoUpdate
TE1 pld ;restore DP
RTS
DoUpdate ANOP
PH4 WindowPtr
_BeginUpdate ;visible region = update region
jsl WindUpdate
PH4 WindowPtr
_EndUpdate ;restore entire visible region
RTS
WindUpdate ANOP
* Make data bank = code bank
phb
phk
plb
* Get current value of PortRect
pushptr PortRect
_getPortRect
lda #14 ;vertical Position
sta Position
lda #10 ;horizontal Position
sta Position+2
PH4 Position
_moveTo
pushptr Header
_drawString
* Initialize disk data location, offset from start of data
lda #(DiskData|-16)
sta DiskDataAddr+2
clc
lda #DiskData
adc #2
sta DiskDataAddr
stz DiskDataOffset
NextVol ANOP
ldx DiskDataOffset
lda DiskData,x
bne ShowIt ;another volume present
jmp Done ;finished
ShowIt ANOP
clc
txa
adc #41
sta DiskDataOffset ;prepare offset for next line
* Move pen to next Position
add2 Position,#12
lda #10
sta Position+2
PH4 Position
_moveTo
* Push address of volume name on stack and print it
PH4 DiskDataAddr
_drawString
add2 DiskDataAddr,#17 ;update
lda #144
sta Position+2
PH4 Position
_moveTo
PH4 DiskDataAddr
PH2 #11
_drawText ;total capacity
PH2 #'K'
_DrawChar ;write K
add2 DiskDataAddr,#11
lda #216
sta Position+2
PH4 Position
_moveTo
PH4 DiskDataAddr
PH2 #11
_DrawText
PH2 #'K'
_DrawChar
add2 DiskDataAddr,#13
jmp NextVol
Done ANOP
plb
RTL
* Startup or shutdown the NDA. On entry, A = 0 for DeskShutDown,
* A is non-zero for DeskStartup.
NDA_Init ANOP
phb
phk
plb
cmp #0 ;starting up?
bne NDA_Init1 ;yes, so do nothing
lda NDAActive ;FreeSpace window open?
beq NDA_Init1 ;no, so branch
PH4 WindowPtr
_CloseWindow ;close the window
stz NDAActive ;set "closed" flag
NDA_Init1 plb
RTL
* The data area begins here
****************************************************************
* Window parameters
****************************************************************
WindowDef ANOP
MainWindow dc I2'WindEnd-MainWindow'
dc I'%1100000010100101' ;window frame def
dc I4'WTitle' ;pointer to window title
dc I4'0' ;refcon
dc I'0,0,0,0' ;zoom rectangle
dc I4'0' ;color table
dc I'0,0' ;origin offset
dc I'250,300' ;height,width data area
dc i'170,300' ;ht, width max window
dc I'0,0' ;vert, horiz scroll
dc I'0,0' ;vert, horiz page
dc i4'0' ;infor bar refcon
dc I2'0' ;info bar height
dc i4'0' ;frame defproc (0=standard)
dc i4'0' ;infor bar defproc
dc I4'WindUpdate' ;content defproc
WindRect dc I'28,20,198,320' ;Content region rectangle
dc I4'-1' ;At the front
dc I4'0' ;Storage
WindEnd ANOP
WTitle DW ' Free Space Catalog '
WindowPtr ds 4 ;pointer to window
WindBot equ WindRect+4 ;depth of window
NDAActive ds 2 ;used as a flag
PortRect ds 8
Header DW 'Volume Capacity Free'
Position ds 4 ;coordinates to move to
VolumeName ds 17
DiskDataOffset ds 2
DiskDataAddr ds 4
DiskData ds 371
vol_list ANOP
dev_name ds 4 ;ptr to devise name string
vol_name dc i4'VolumeName' ;ptr to vol name string
total_blocks ds 4 ;size in blocks
free_blocks ds 4 ;# blocks unused
file_sys_id ds 2
capacity equ total_blocks
freeK equ free_blocks
dev_name_str DW '.D1'
DW '.D2'
DW '.D3'
DW '.D4'
DW '.D5'
DW '.D6'
DW '.D7'
DW '.D8'
dev_name_end DW '.D9'
END